package com.tieto.springboot.demo.springbootweb;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tieto.springboot.demo.springbootweb.bean.Product;

@Controller
public class ProductController {

	private static final String MODEL_NAME_PRODUCT = "product";
	
	@RequestMapping("/product")
	public String getProduct(Model model,HttpSession session){
		
		Product product = new Product();
		product.setProductName("4K电视机");
		product.setProductPrice(4999.99);
		
		model.addAttribute("productName", product.getProductName());
		model.addAttribute("productPrice", product.getProductPrice());
		
		session.setAttribute("user", "tony tan");
		return MODEL_NAME_PRODUCT;
	}
	
	@RequestMapping(value={"/","/index"})
	public String getHomePage(){
		return "index";
	}
}
